package com.dankegongyu.lib.dropdownmenu;

import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.dankegongyu.lib.R;
import com.dankegongyu.lib.base.BaseAppActivity;
import com.dankegongyu.lib.common.widget.dropdown.DropDownMenu;
import com.dankegongyu.lib.common.widget.dropdown.DropDownMenuTheme;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author wupuquan
 * @version 1.0
 * @since 2018/5/15 11:08
 */
public class DropDownMenuActivity extends BaseAppActivity {

    @BindView(R.id.dropDownMenu)
    DropDownMenu mDropDownMenu;
    @BindView(R.id.btn_theme1)
    Button mBtnTheme1;
    @BindView(R.id.btn_theme2)
    Button mBtnTheme2;

    private TestDropDownMenuAdapter mTabAdapter;

    @Override
    public int getContentViewLayoutId() {
        return R.layout.activity_dropdownmenu;
    }

    @Override
    public void init(@Nullable Bundle savedInstanceState) {
        mDropDownMenu.setOnMenuChangedListener(new DropDownMenu.OnMenuListener() {
            @Override
            public void onMenuTabClick(int position, boolean isMenuContentShowing) {

            }

            @Override
            public void onMenuContentVisibleChanged(boolean visible) {

            }
        });
        mDropDownMenu.getDropDownMenuTab()
                .showTabDividers(false);

        List<DropDownMenuBean> tabList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            final Button button = new Button(this);
            button.setText("content" + i);
            button.setPadding(20, 20, 20, 20);
            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mTabAdapter.setActive(button, true);
                }
            });
            tabList.add(new DropDownMenuBean(i == 4 ? "" : "打扫" + i, button));
        }
        mTabAdapter = new TestDropDownMenuAdapter(this, tabList);
        mDropDownMenu.setDropDownMenuAdapter(mTabAdapter);
    }

    @OnClick({R.id.btn_theme1, R.id.btn_theme2})
    public void onViewClicked(View v) {
        switch (v.getId()) {
            case R.id.btn_theme1:
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//                DropDownMenuTheme theme1 = new DropDownMenuTheme.Builder(0xff333333, 0xff3dbcc6)
//                        .setBackgroundColor(Color.WHITE).build();
//                mDropDownMenu.updateTheme(theme1);
                break;
            case R.id.btn_theme2:
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//                DropDownMenuTheme theme2 = new DropDownMenuTheme.Builder(0xffffffff, 0xffffffff)
//                        .setBackgroundColor(Color.TRANSPARENT).build();
//                mDropDownMenu.updateTheme(theme2);
                break;
        }
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void doBusiness() {

    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }
}
